Das hier fällt mir da gerade noch ein...
Division von 32 bit aus dem AtariAge Forum entnommen und erfolgreich bei "golucky" angewendet:
//--------------------------
;code by flashjazzcat
; Divide Num1 by Num2 and place result in Num1
; Remainder is left in Num3, which MUST be immediately after Num1 in RAM
; Optimised for size rather than speed
;
.local DivDWord ; Divide Num1 by Num2 and place result in Num1
lda #0 ; preset remainder to 0
ldx #3
@
sta Num3,x
dex
bpl @-
ldy #32 ; repeat for each bit
DivLoop
clc ; clear carry so we can use ROL throughout
ldx #248 ; dividend lb & hb*2, msb -> Carry
@
rol.w Num1-248,x ; .w ensures ZP addressing is never used
inx
bne @-
sec
ldx #252
@
lda.w Num3-252,x
sbc.w Num2-252,x
pha
inx
bne @-
bcs @+
pla
pla
pla
pla
bcc Skip
@
ldx #3
@
pla
sta Num3,x
dex
bpl @-
inc Num1 ; and increment result because divisor fit
Skip
dey
bne DivLoop
rts
;----------------
.endl
//--------------------------
;code by flashjazzcat
; Multiply Num1 by Num2, storing result in Num3
; Optimised for size rather than speed
.local MulDWord ; Multiply Num1 by Num2, storing result in Num3
ldx #3
lda #0
@
sta Num3+4,x ; clear upper bits of product
dex
bpl @-
ldy #32 ; loop for each bit
MultLoop
clc ; clear carry so we can use ROR on all four bytes
ldx #3
@
ror Num1,x ; divide multiplier by 2
dex
bpl @-
bcc Rotate
clc
ldx #253
@
lda.w Num3-249,x
adc.w Num2-253,x
sta.w Num3-249,x
inx
bne @-
lda Num3+7
adc Num2+3
Rotate
ror ; rotate partial product
sta Num3+7
ldx #6
@
ror Num3,x
dex
bpl @-
dey
bne MultLoop
rts
.endl
//--------------------------
Num1 .ds 4
Num3 .ds 8 ; must follow Num1 for Div to work
Num2 .ds 4